package IteratorPattern;

import java.util.ArrayList;

public class BookShelf implements Aggreate{
    private ArrayList books;
    public BookShelf(int initalize) {
        this.books = new ArrayList<>(initalize);
    }
    public Book getBookAt(int index){
        return (Book)books.get(index);
    }
    public void appendBook(Book book){
        books.add(book);
    }
    public int getLength(){
        return books.size();
    }

    @Override
    public Iterator iterator() {
        return new BookShelfIterator(this);
    }
}
